#!/bin/bash

# This is a wrapper script for cmake. All we do is check whether the cmake
# binary exists and execute it to generate the Makefiles.

# Check whether PARSEC environment variables are set
if [ -z "${PARSECDIR}" ]; then
  echo "Error: Variable PARSECDIR not set."
  exit 1
fi

if [ -z "${PARSECPLAT}" ]; then
  echo "Error: Variable PARSECPLAT not set."
  exit 1
fi

# Warn user if any arguments are specified (This is not a GNU autoconf script)
if [ ! -z "$@" ]; then
  echo "Warning: Ignoring specified arguments"
fi

# Execute cmake with correct flags

${PARSECDIR}/pkgs/tools/cmake/inst/${PARSECPLAT}/bin/cmake -G "Unix Makefiles" -D CMAKE_INSTALL_PREFIX=${PARSECDIR}/pkgs/apps/raytrace/inst/${PARSECPLAT} -D CMAKE_CXX_FLAGS="${CXXFLAGS}" -D USE_PBOS=1 -D NEED_ARB_WRAPPERS=0 -D CMAKE_LIBRARY_PATH=${PARSECDIR}/pkgs/libs/mesa/inst/${PARSECPLAT}/lib -D CMAKE_INCLUDE_PATH=${PARSECDIR}/pkgs/libs/mesa/inst/${PARSECPLAT}/include .

